// store/modules/app

import { defineStore } from 'pinia'
// import { store } from '../../store'
import store from '../index';
import i18n from '../../locales'

const useAppStore = defineStore('app', {
    state: () => {
        return {
            locale: localStorage.getItem('lang') || 'zhCn',
            Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : ''
        }
    },
    actions: {
        SET_LOCALE(locale: any) { //语言切换
            this.locale = locale
            localStorage.setItem('lang', locale)
            i18n.global.locale.value = locale
        },
        setToken(state: any) {
            this.Authorization = state

            localStorage.setItem('Authorization', state)
        }

    },


})

export function useAppStoreHook() {
    return useAppStore(store)
}
export default useAppStore


